﻿using System;
using Core.Framework.Model.Common;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;

namespace Core.DataAccess.Model.Project.NLP
{
    /// <summary>
    /// 自然语言
    /// </summary>
    public partial class ProjectNLPContext : DbContext
    {
        public ProjectNLPContext()
        {
        }

        public ProjectNLPContext(DbContextOptions<ProjectNLPContext> options)
            : base(options)
        {
        }

        public virtual DbSet<DicEnumType> DicEnumType { get; set; }
        public virtual DbSet<DicExtendContent> DicExtendContent { get; set; }
        public virtual DbSet<DicRequest> DicRequest { get; set; }
        public virtual DbSet<DicType> DicType { get; set; }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            if (!optionsBuilder.IsConfigured)
            {
                optionsBuilder
                    // 数据操作日志
                    .UseLoggerFactory(EFLogger.GetLoggerFactory())
                    .UseSqlServer(CoreStartupHelper.GetConnectionValue("NLP_SqlServerConnection"));
            }
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<DicEnumType>(entity =>
            {
                entity.ToTable("Dic_Enum_Type");

                entity.Property(e => e.Id).HasColumnName("id");

                entity.Property(e => e.Addtime)
                    .HasColumnName("addtime")
                    .HasColumnType("datetime")
                    .HasDefaultValueSql("(getdate())");

                entity.Property(e => e.Title)
                    .HasColumnName("title")
                    .HasMaxLength(50)
                    .IsUnicode(false);
            });

            modelBuilder.Entity<DicExtendContent>(entity =>
            {
                entity.ToTable("Dic_Extend_Content");

                entity.Property(e => e.Id).HasColumnName("id");

                entity.Property(e => e.Addtime)
                    .HasColumnName("addtime")
                    .HasColumnType("datetime")
                    .HasDefaultValueSql("(getdate())");

                entity.Property(e => e.Content)
                    .HasColumnName("content")
                    .IsUnicode(false);

                entity.Property(e => e.DicType).HasColumnName("dicType");

                entity.Property(e => e.Type).HasColumnName("type");
            });

            modelBuilder.Entity<DicRequest>(entity =>
            {
                entity.ToTable("Dic_Request");

                entity.Property(e => e.Id).HasColumnName("id");

                entity.Property(e => e.AddTime)
                    .HasColumnName("addTime")
                    .HasColumnType("datetime")
                    .HasDefaultValueSql("(getdate())");

                entity.Property(e => e.Click)
                    .HasColumnName("click")
                    .HasMaxLength(14)
                    .IsUnicode(false);

                entity.Property(e => e.Input)
                    .HasColumnName("input")
                    .HasMaxLength(300)
                    .IsUnicode(false);

                entity.Property(e => e.IpAddress)
                    .HasColumnName("ip_address")
                    .HasMaxLength(15)
                    .IsUnicode(false);

                entity.Property(e => e.ReqUrl)
                    .HasColumnName("reqUrl")
                    .HasMaxLength(300)
                    .IsUnicode(false);

                entity.Property(e => e.Ret)
                    .HasColumnName("ret")
                    .IsUnicode(false);
            });

            modelBuilder.Entity<DicType>(entity =>
            {
                entity.ToTable("Dic_Type");

                entity.Property(e => e.Id).HasColumnName("id");

                entity.Property(e => e.Addtime)
                    .HasColumnName("addtime")
                    .HasColumnType("datetime")
                    .HasDefaultValueSql("(getdate())");

                entity.Property(e => e.ProjectToken)
                    .HasColumnName("projectToken")
                    .HasMaxLength(21)
                    .IsUnicode(false);

                entity.Property(e => e.Title)
                    .HasColumnName("title")
                    .HasMaxLength(50)
                    .IsUnicode(false);

                entity.Property(e => e.UserKey).HasColumnName("userKey");
            });
        }
    }
}
